#! /usr/bin/env python
# -*- coding: utf-8 -*-

import os,sys
sys.path.insert(0,os.path.abspath('..'))
sys.path.insert(0,os.path.abspath('../../'))

def setup(src_path,setup_file,out_path,server_name):
    src_path = os.path.abspath(src_path)
    setup_file = os.path.abspath(setup_file)
    out_path = os.path.abspath(out_path)
    os.chdir(src_path)
    cmds = [
        r"del /Q /S /A:-H %s\ " % out_path,
        r"python %s py2exe" % setup_file,
        r"xcopy /E /H /R /K /Y %s\dist\*.* %s\ " % (src_path,out_path),
        r"rd   /Q /S %s\build" % src_path,
        r"rd   /Q /S %s\dist" % src_path,
    ]

    for cmd in cmds:
        os.system(cmd)


if __name__ == "__main__":
    setup(
        r'.\Src\tracker',
        r'.\Src\tracker\TaskServerConsoleSetup.py',
        r'.\win32_console\tracker',
        r'TaskServerWin32'
    )

